package stack;

/**
 * @author dx
 * @version 1.0
 * @date 2022/3/29 11:09
 * @description:  删除最外层的括号
 */
public class Remove_Out_Parent {
    public String removeOuterParentheses(String s) {
        StringBuilder sb = new StringBuilder();
        int level = 0;
        for (char c : s.toCharArray()) {
            if (c == ')') level--;
            if (level >= 1) sb.append(c);
            if (c == '(') level++;
        }
        return sb.toString();
    }


}
